/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlador;

import java.io.*;
/**
 *
 * @author Jaime
 */
public class archivos {
    public void guardaraarchivo(String path,String pagina){
        File f;
        f=new File(path);        
        try{
            FileWriter w=new FileWriter(f);
            BufferedWriter bw=new BufferedWriter(w);
            PrintWriter wr=new PrintWriter(bw);
            wr.write(pagina);
            //wr.append("algo");
            wr.close();
            bw.close();                    
        }catch(IOException e){
            
            
        }
        
    }
    
    public String leerarchivo(String path){
        String res="";
        
        File f;
        String linea;
        
        
        StringBuilder sb = new StringBuilder();
        f = new File(path);
        FileReader fr;
        BufferedReader br = null;
    
        try{
            fr = new FileReader(f);
            br = new BufferedReader(fr);
 
            while ((linea = br.readLine()) != null) {
                sb.append(linea);
                sb.append('\n');
            }
            res=sb.toString();                    
        }catch(IOException e){
            
            
        }
        
        return res;
    }
}
